<?php

require_once 'BluesCoders/Context/Builder/Xml.php';
require_once 'BluesCoders/Event/Dispatcher.php';
require_once 'BluesCoders/Application/Event.php';

/**
 * 
 *
 * @author miho
 */
class BluesCoders_Application {

    protected $_context;
    protected $_basePath;
    protected $_configFolderName = 'config';
    protected $_contextDefinitionFileName = 'applicationContext.xml';

    public function  __construct() {
        
    }

    public function dispatch() {
        $this->_initializeContext();

        BluesCoders_Event_Dispatcher::getIsntance()->dispatchEvent(
            new BluesCoders_Application_Event(
                    BluesCoders_Application_Event::START_UP,
                    $this
                )
        );
    }

    protected function _initializeContext() {
        $pathToContext = $this->_configFolderName . DIRECTORY_SEPARATOR . $this->_contextDefinitionFileName;
        $this->_context = BluesCoders_Context_Builder_Xml::build($pathToContext, $this->_basePath);
    }

    /**
     *
     * @return BluesCoders_Application 
     */
    public static function newInstance() {
        return new self();
    }

    public function setBasePath($value) {
        $this->_basePath = $value;
        return $this;
    }

    public function setConfigFolderName($value) {
        $this->_configFolderName = $value;
        return $this;
    }

    public function getContextDefinitionFileName($value) {
        $this->_contextDefinitionFileName = $value;
        return $this;
    }

    public function getContext() {
        return $this->_context;
    }

}
?>
